﻿{extend name="common/inside"}


{block name="table"}
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="r">共有数据：<strong>88</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th>序号</th>
                <th>商品名称</th>
                <th>商品类型</th>
                <th>发布者</th>
                <th>商品状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $goods as $good}
            <tr class="text-c">
                <td>{$good->goods_id}</td>
                <td>{$good->goods_name}</td>
                <td>
                    {foreach $types as $type}
                        {if $good->goods_type == $type->type_id}
                            <font color="#483d8b">{$type->type_name}</font>
                        {/if}
                    {/foreach}
                </td>
                <td>
                    {if empty($good->user->user_name)}
                        <font color="#ffa07a">此账号已被删除</font>
                    {else /}
                        {$good->user->user_name}
                    {/if}
                </td>
                <td>{$good->goodState()}</td>
                <td class="td-manage">

                    <a title="查看商品信息" href="javascript:;" onclick="member_edit('查看商品信息','{:str_replace('id',$good->goods_id,url('/goods/id'))}','4','','600')"
                       class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    <a title="查看商品出价" href="javascript:;" onclick="member_edit('查看商品出价','{:url('/bidder',['id' => $good->goods_id])}','4','','600')"
                       class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe63f;</i></a>
                    <a title="删除" href="javascript:;" onclick="member_del(this,{$good->goods_id})" class="ml-5"
                       style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>

                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
    </div>
</div>

{/block}


{block name='js'}
<script>

    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){

            var url = "{:url('/goods/id')}"
            console.log(url)
            url = url.replace('id',id)

            console.log(url)
            $.ajax({
                type: 'DELETE',
                url: url,
                dataType: 'json',
                success: function(data){
                    console.log(data)
                    if (data.state == 'success'){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    } else {
                        layer.msg('删除失败!',{icon:2,time:1000});
                    }

                },
                error:function(data) {
                    console.log(data)

                    // console.log(data.msg);
                },
            });
        });
    }

</script>

{/block}




